import { createStore, compose, applyMiddleware } from "redux";
import reducer from "./reducer";

// 用于react做异步请求处理
import thunk from "redux-thunk";

// 为了方便调试，配置redux-devtools插件工具，需要安装chrome插件
const composeEnhancers = (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;

// 通过中间件调用
const store = createStore(reducer, composeEnhancers(
  applyMiddleware(thunk)
));

export default store;